{% extends base_template %}
{% load i18n %}
{% load url from future %}
{% load xadmin_tags %}
{% load crispy_forms_tags %}

{% block extrahead %}{{ block.super }}
{% url 'admin:jsi18n' as jsi18nurl %}
<script type="text/javascript" src="{{ jsi18nurl|default:"../../../jsi18n/" }}"></script>
{% endblock %}

{% block bodyclass %}{{ opts.app_label }}-{{ opts.object_name.lower }} change-form{% endblock %}

{% block breadcrumbs %}
<ul class="breadcrumb">
  <li><a href="{% url 'admin:index' %}">{% trans 'Home' %}</a> <span class="divider">/</span></li>
  <li>
    {% if has_view_permission %}
    <a href="{% url opts|admin_urlname:'changelist' %}">{{ opts.verbose_name_plural|capfirst }}</a>
    {% else %}{{ opts.verbose_name_plural|capfirst }}{% endif %} <span class="divider">/</span>
  </li>
  <li class="active">
    {% if add %}{% trans 'Add' %} {{ opts.verbose_name }}{% else %}{{ original|truncatewords:"18" }}{% endif %}
  </li>
</ul>
{% endblock %}

{% block content %}
<form class="exform" {% if has_file_field %}enctype="multipart/form-data" {% endif %}action="{{ form_url }}" method="post" id="{{ opts.module_name }}_form">{% csrf_token %}
  {% view_block 'form_top' %}
  {% if save_on_top %}{% block submit_buttons_top %}{% include "xadmin/includes/submit_line.html" %}{% endblock %}{% endif %}

  {% block form_legend %}
  <legend>
    {% block object-tools %}
    {% if change %}
    <div class="pull-right">
      {% view_block 'object_tools' %}
    </div>
    {% endif %}
    {% endblock %}
    {% if model_icon %}<i class="icon-{{model_icon}}"><sub class="icon-{% if add%}plus{%else%}pencil{%endif%}"></sub></i> {% endif %}
    {{ title }}
  </legend>
  {% endblock %}

  {% if errors %}
      <p class="text-error">
      {% blocktrans count counter=errors|length %}Please correct the error below.{% plural %}Please correct the errors below.{% endblocktrans %}
      </p>
      {{ form.non_field_errors }}
  {% endif %}

  {% view_block 'before_fieldsets' %}

  {% crispy form %}

  {% view_block 'after_fieldsets' %}

  {% block submit_buttons_bottom %}{% include "xadmin/includes/submit_line.html" %}{% endblock %}
</form>
{% endblock %}
